package avicit.bdp.dms.dss.enums;

import avicit.bdp.core.enums.BaseEnum;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2021-03-29 17:55
 * @类说明：
 * @修改记录：
 */
public enum ResourceStatus implements BaseEnum {

    // 状态 0-未发布 1-已发布 2-已撤回
    UNPUBLISHED(0, "未发布"),
    PUBLISHED(1, "已发布"),
    WITHDRAWN(2, "已撤回");

    private final int code;
    private final String description;

    ResourceStatus(int code, String description){
        this.code = code;
        this.description = description;
    }

    @Override
    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static String getDescByCode(Integer code) {
        if (code != null) {
            ResourceStatus[] values = ResourceStatus.values();
            for (ResourceStatus resourceStatus : values) {
                if (resourceStatus.getCode() == code) {
                    return resourceStatus.getDescription();
                }
            }
        }
        return null;
    }

}
